package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.geom.Rectangle;
    import flash.utils.ByteArray;

    public class BitmapMain extends Sprite
    {
        public function BitmapMain()
        {
            var blueSquare:BitmapData = new BitmapData(20, 20, false, 0xFF0000FF);
            var greenSquare:BitmapData = new BitmapData(30, 30, false, 0xFF00FF00);

            var rectRegion:Rectangle = new Rectangle(5, 5, 10, 10);

            var greenPixels:ByteArray = greenSquare.getPixels(rectRegion);
            greenPixels.position = 0;

            blueSquare.setPixels(rectRegion, greenPixels);

            var blueBmp:Bitmap = new Bitmap(blueSquare);
            this.addChild(blueBmp);

            var greenBmp:Bitmap = new Bitmap(greenSquare);
            greenBmp.x = 40;
            this.addChild(greenBmp);
        }
    }
}